<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
</head>
<body>
<div id="app">
并发请求：将多个请求在同一时刻发送到后端接口，最后再集中处理每个请求的响应结果
</div>
<script>
    //1.创建一个查询所有的请求
    function findAll() {
        return axios.get("http://localhost:8080/vue/findAll");
    }
    //2.创建一个保存的请求
    function save(){
        return axios.post("http://localhost:8080/vue/save",{
            id:"1006",
            lastName:"vue",
            email:"vue.js@vue.com",
            gender:"1",
            department:{id:"101",departmentName:"D-AA"},
            birth:new Date()
        });
    }

    //3.并发执行
    axios.all([findAll(),save()]).then(
        //将一组函数的相应结果汇总处理，参数分别对应第一个方法的响应和第二个方法的响应
        axios.spread(function (res1,res2) {
            console.log(res1.data);
            console.log(res2.data);
        })
    );
    var app = new Vue({
        el: '#app',
        data: {},
        methods: {}
    });
</script>
</body>
</html>